package wang.d2.interface_demo;

import java.util.ArrayList;

public class StudentOperatorImp2 implements StudentOperator {
    @Override
    public void printfallinfo(ArrayList<Student> Students) {
        int count1 = 0;
        int count2 = 0;
        System.out.println("----------全部学生信息-----------");
        for (int i = 0; i < Students.size(); i++) {
            Student student = Students.get(i);
            if (student.getSex() == '男'){
                count1++;
            }else {
                count2++;
            }
            System.out.println("学生姓名：" + student.getName() + ",学生性别：" + student.getSex() + ",成绩：" + student.getScore());

        }
        System.out.println("学生中，男学生个数为："+ count1 +",女学生个数为：" + count2);
        System.out.println("----------------------------------------");


    }

    @Override
    public void printfallscore(ArrayList<Student> students){
        double max = students.get(0).getScore();
        double min = students.get(0).getScore();
        double counbt = 0.0;
        for (int i = 0; i < students.size(); i++) {
            Student s = students.get(i);
            if (max < s.getScore()) max = s.getScore();
            if (min > s.getScore()) min = s.getScore();
            counbt += s.getScore();

        }
        System.out.println("学生的平均成绩为：" + (counbt - max - min) / (students.size() - 2));
    }
}
